﻿<Application x:Class="HigLabo.DbSharpApplication.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:ctrl="clr-namespace:System.Windows.Controls;assembly=PresentationFramework"
             xmlns:hig="clr-namespace:HigLabo.Wpf.Converter;assembly=HigLabo.Wpf"
             xmlns:dbs="clr-namespace:HigLabo.DbSharpApplication"
             xmlns:p="clr-namespace:HigLabo.DbSharpApplication.Properties"
             StartupUri="Windows/MainWindow.xaml"
             Startup="Application_Startup">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Styles/Common.xaml"/>
                <ResourceDictionary Source="Styles/Button.xaml"/>
                <ResourceDictionary Source="Styles/ListBox.xaml"/>
            </ResourceDictionary.MergedDictionaries>

            <hig:DateConverter x:Key="DateConverter" Format="yyyy/MM/dd" />
            <hig:DateConverter x:Key="DateHHmmConverter" Format="yyyy/MM/dd HH:mm" />
            <hig:DateConverter x:Key="DateHHmmssConverter" Format="yyyy/MM/dd HH:mm:ss" />
            <hig:DateConverter x:Key="ExecutedTimeConverter" Format="yyyy/MM/dd HH:mm:ss.fffffff" />
            <hig:DateConverter x:Key="UpdateTimeConverter" Format="MM/dd HH:mm:ss" />
            <hig:DateConverter x:Key="LastAlteredTimeConverter" Format="MM/dd HH:mm:ss" />
            <hig:BooleanTextConverter x:Key="DataTypeBooleanTextConverter" ValueWhenTrue="Yes" ValueWhenFalse="" />
            <hig:RecentFilePathConverter x:Key="RecentFilePathConverter" />
            <hig:StringBrushConverter x:Key="ProcessTypeBackgroundConverter" />
            <hig:StringBrushConverter x:Key="DatabaseObjectTypeBackgroundConverter" />

            <dbs:DataTypeLengthConverter x:Key="DataTypeLengthConverter" />

            <p:Resources x:Key="Resources" />

            <ctrl:DataGridTextColumn x:Shared="False" x:Key="DataTypeOrdinal" Header="" Binding="{Binding Path=Ordinal}" IsReadOnly="True" Width="30"></ctrl:DataGridTextColumn>
            <ctrl:DataGridTextColumn x:Shared="False" x:Key="DataTypeColumnName" Header="{x:Static p:Resources.ColumnName}" Binding="{Binding Path=Name}" IsReadOnly="True" Width="160"></ctrl:DataGridTextColumn>
            <ctrl:DataGridTextColumn x:Shared="False" x:Key="DataTypeDbType" Header="{x:Static p:Resources.DbType}" Binding="{Binding Path=DbType}" IsReadOnly="True" Width="120"></ctrl:DataGridTextColumn>
            <ctrl:DataGridTextColumn x:Shared="False" x:Key="DataTypeLength" Header="{x:Static p:Resources.Length}" Binding="{Binding Path=Length, Converter={StaticResource DataTypeLengthConverter}}" IsReadOnly="True"></ctrl:DataGridTextColumn>
            <ctrl:DataGridTextColumn x:Shared="False" x:Key="DataTypePrecision" Header="{x:Static p:Resources.Precision}" Binding="{Binding Path=Precision}" IsReadOnly="True"></ctrl:DataGridTextColumn>
            <ctrl:DataGridTextColumn x:Shared="False" x:Key="DataTypeScale" Header="{x:Static p:Resources.Scale}" Binding="{Binding Path=Scale}" IsReadOnly="True"></ctrl:DataGridTextColumn>
            <ctrl:DataGridTextColumn x:Shared="False" x:Key="DataTypeUserTableTypeName" Header="UserTable" Binding="{Binding Path=UserTableTypeName}" IsReadOnly="True" Width="120"></ctrl:DataGridTextColumn>
            <ctrl:DataGridTextColumn x:Shared="False" x:Key="DataTypeUdtTypeName" Header="UdtType" Binding="{Binding Path=UdtTypeName}" IsReadOnly="True" Width="120"></ctrl:DataGridTextColumn>
            <ctrl:DataGridTextColumn x:Shared="False" x:Key="DataTypeEnumName" Header="{x:Static p:Resources.EnumName}" Binding="{Binding Path=EnumName}" Width="120"></ctrl:DataGridTextColumn>
            <ctrl:DataGridTextColumn x:Shared="False" x:Key="DataTypeEnumValues" Header="{x:Static p:Resources.EnumValues}" Binding="{Binding Path=EnumValues}" IsReadOnly="True" Width="120"></ctrl:DataGridTextColumn>

            <ctrl:DataGridTextColumn x:Shared="False" x:Key="DataTypeAllowNull" Header="{x:Static p:Resources.AllowNull}" Binding="{Binding Path=AllowNull, Converter={StaticResource DataTypeBooleanTextConverter}}" IsReadOnly="True"></ctrl:DataGridTextColumn>
            <ctrl:DataGridTemplateColumn x:Shared="False" x:Key="DataTypeAllowNullEditable" Header="{x:Static p:Resources.AllowNull}">
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <CheckBox IsChecked="{Binding Path=AllowNull, UpdateSourceTrigger=PropertyChanged}" Width="20"></CheckBox>
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </ctrl:DataGridTemplateColumn>
            <ctrl:DataGridTextColumn x:Shared="False" x:Key="DataTypeIsPrimaryKey" Header="{x:Static p:Resources.PrimaryKey}" Binding="{Binding Path=IsPrimaryKey, Converter={StaticResource DataTypeBooleanTextConverter}}" IsReadOnly="True"></ctrl:DataGridTextColumn>
            <ctrl:DataGridTextColumn x:Shared="False" x:Key="DataTypeIsIdentity" Header="Identity" Binding="{Binding Path=IsIdentity, Converter={StaticResource DataTypeBooleanTextConverter}}" IsReadOnly="True"></ctrl:DataGridTextColumn>
            <ctrl:DataGridTextColumn x:Shared="False" x:Key="DataTypeIsRowGuidCol" Header="IsRowGuidCol" Binding="{Binding Path=IsRowGuidCol, Converter={StaticResource DataTypeBooleanTextConverter}}" IsReadOnly="True"></ctrl:DataGridTextColumn>

            <ctrl:DataGridTextColumn x:Shared="False" x:Key="DataTypeParameterDirection" Header="Direction" Binding="{Binding Path=ParameterDirection}" IsReadOnly="True"></ctrl:DataGridTextColumn>

            <DataTemplate x:Key="DatabaseObjectDataTemplate">
                <StackPanel Orientation="Horizontal">
                    <CheckBox IsChecked="{Binding Path=IsChecked}"></CheckBox>
                    <TextBlock Text="{Binding Path=Item.LastAlteredTime, Converter={StaticResource LastAlteredTimeConverter}}" 
                               Background="{Binding Path=Item.ObjectType, Converter={StaticResource DatabaseObjectTypeBackgroundConverter}}"
                               FontWeight="Bold" Margin="0,0,5,0" Padding="5,0,5,0"></TextBlock>
                    <TextBlock Text="{Binding Path=Item.Name}" TextWrapping="Wrap" 
                               HorizontalAlignment="Left" TextAlignment="Left"></TextBlock>
                </StackPanel>
            </DataTemplate>

            <dbs:ProgressListBoxDataTemplateSelector x:Key="ProgressListBoxDataTemplateSelector" />

            <DataTemplate x:Key="ProgressListBoxDataTemplate">
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding Path=ExecutedTime, Converter={StaticResource ExecutedTimeConverter}}" 
                               FontWeight="Bold" Margin="0,0,10,0"></TextBlock>
                    <TextBlock Text="{Binding Path=Message}" TextWrapping="Wrap" 
                               HorizontalAlignment="Left" TextAlignment="Left"></TextBlock>
                </StackPanel>
            </DataTemplate>

            <DataTemplate x:Key="SourceCodeFileGeneratedDataTemplate">
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding Path=ExecutedTime, Converter={StaticResource ExecutedTimeConverter}}" 
                               FontWeight="Bold" Margin="0,0,10,0"></TextBlock>
                    <TextBlock Text="{Binding Path=FileName}" TextWrapping="Wrap" 
                               HorizontalAlignment="Left" TextAlignment="Left"></TextBlock>
                </StackPanel>
            </DataTemplate>


        </ResourceDictionary>
    </Application.Resources>
</Application>
